package com.suxin.socket.yinfei.session;

import lombok.extern.slf4j.Slf4j;

import javax.websocket.Session;
import java.io.IOException;

/**
 * @author Tang
 * @classname AbstractSessionConnectionHolder
 * @description [  ]
 * @date 2021/8/17 22:39
 */
@Slf4j
public abstract class AbstractSessionConnectionHolder implements SessionConnectionHolder {

    @Override
    public void onOpen(Session session) {
        log.info("有新的客户端连接进来...{}", session.getId());
    }

    @Override
    public void onClose(Session session) {
        if (session != null && session.isOpen()) {
            try {
                session.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}